<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    //     let arr = [3,4,6]
    //     //reduce 函数  previous上一个返回函数（没有就默认第一个），content 当前元素
    //     const result =arr.reduce((previous,content) => {
    //         return previous+content
    //     })
    //     //上一个返回值是100
    //    const result2 = arr.reduce((previous,content) => {
    //         return  previous +content
    //    },100)
    //    console.log(result2)

    //实现去重操作
    
    let arr = [1,4,2,5,6,3,2,4,6]
    //第一种reduce方法
    const result = arr.reduce((previous,content) => {
        if(previous.indexOf(content) === -1){
           previous.push(content)
        }
        return previous
    },[])
    console.log(result)

    //第二种set集合
    let set = new Set(arr)
    console.log(set)
    </script>
</body>
</html>